package x.y.z;

import java.util.LinkedList;
import java.util.Queue;

public class LeetCode_0559 {
    public int maxDepth(Node root) {
        if (root == null) {
            return 0;
        }
        Queue<Node> queue = new LinkedList<>();
        queue.offer(root);
        int depth = 0;
        while (!queue.isEmpty()) {
            int size = queue.size();
            while (size > 0) {
                Node node = queue.poll();
                for (Node childNode : node.children) {
                    queue.offer(childNode);
                }
                size--;
            }
            depth++;
        }
        return depth;
    }
}
